<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <img src="./生命周期.png" alt="宁德网络出错啦">
    <title>Document</title>
</head>

<body>
    <div id="root">
        <div>
            <h1>你好，{{name}}</h1>
            <h1>当前的n值是：{{n}}</h1>
            <button @click="add">点我n+1</button>
            <button @click="bye">销毁</button>
        </div>`
    </div>
    <img src="./process.png" alt="">
</body>
<script>
    new Vue({
        el: "#root",
        // 确定模板片段
        // template: `  `,
        data: {
            name: "SWPU",
            n: 1,
        },
        methods: {
            add() {
                console.log("add")
                this.n++
                console.log(this.n)
            },
            bye() {
                this.$destroy()
                console.log("bye")
            }
        },
        beforeCreate() {
            console.log("beforeCreate")
            console.log(this)
            // debugger;
        },
        created() {
            console.log("created")
            console.log(this)
        },
        beforeMount() {
            // debugger;
            console.log("beforemounted")
        },
        mounted() {
            console.log("mounted")
        },
        beforeUpdate() {
            console.log("beforeUpdate")
        },
        updated() {
            console.log("update")
        },
        beforeDestroy() {
            console.log("beforeDestroy")
            this.add()
        },
        destroyed() {
            console.log("destroyed")
        },



    })

</script>

</html>